package view;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import model.State;

/**
 * Class to create the name panel portion of the LoginGUI.
 * @author Sarah George & Kevin Anderson
 * @version Autumn 2012
 */
@SuppressWarnings("serial")
public class NamePanel extends JPanel {
	
	/**
	 * Field to hold the initial text for the text field.
	 */
	private static String INIT_TEXT = "mary";
	
	/**
	 * Field to hold the current state of the system.
	 */
	private State my_state;
	
	/**
	 * Field to hold the LoginGUI JFrame.
	 */
	private JFrame my_frame;
	
	/**
	 * Constructor for a name panel.
	 * @param the_state the current state of the system.
	 * @param the_frame the login gui JFrame.
	 */
	public NamePanel(State the_state, JFrame the_frame) {
		super();
		my_state = the_state;
		my_frame = the_frame;
		setup();
	}
	
	/**
	 * Method to setup a name panel.
	 */
	public void setup() {
		JTextField name_text = new JTextField(INIT_TEXT);
		name_text.setPreferredSize(new Dimension(100,20));
		ValidateAction va = new ValidateAction(name_text, my_state, my_frame);
		JButton validate = new JButton(va);
		this.add(name_text);
		this.add(validate);
	}
}//End class Name Panel.